// pages/adopt/adopt.js
var call = require("../../utils/ajax.js")

var host = 'http://localhost:8085/';
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        currentIndexNav: 0,
        index: 0,
        text: ['发布中', '待审核', '已审批'],
        poseList: [],
        whenseekList: [],
        seekList: [],
        token: "",
        publisher_id: "",
      URL:""
    },

    activeNav: function(e) {
        this.setData({
            currentIndexNav: e.currentTarget.dataset.index
        })
        this.onLoad()
    },


    onLoad: function(options) {
              
                this.setData({
                        URL:app.globalData.URL
                    })
        if(!app.globalData.userState){
            wx.showToast({
                title: '您未登录！',
                icon: 'none',    //如果要纯文本，不要icon，将值设为'none'
                duration: 2000     
              }) 
            setTimeout(() => {
                wx.navigateBack({
                    delta: 1, // 回退前 delta(默认为1) 页面
                })
            }, 1000)
        }
        var that = this;
        var jj = wx.getStorageSync('openID')
        var url = "Pet/SelectMePetListDai?publisher_id=" + jj
        var url1 = "Adopt/SelectAdoptByStateCount"
        var url2 = "Adopt/SelectAdoptPeoInfo"
        call.request1(url, {}, function(res) {
            console.log(res)
            that.setData({
                poseList: res.data
            })
        })
        call.getData1(url1, function(res) {
            console.log(res)
            that.setData({
                whenseekList: res.date
            })
        })
        call.getData1(url2, function(res) {
            console.log(res)
            that.setData({
                seekList: res.date
            })
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {},

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        this.onLoad();
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    }
})